Skip to content

Commit

Permalink
Use QUnit for node tests
Browse files Browse the repository at this point in the history
So that we only have to maintain a single framework.
  • Loading branch information
carhartl committed Jun 23, 2023
1 parent 19c9747 commit aecb4b3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 33 deletions.
6 changes: 2 additions & 4 deletions Gruntfile.js
Expand Up @@ -42,9 +42,6 @@ const config = {
}
}
},
nodeunit: {
all: 'test/node.js'
},
watch: {
options: {
livereload: true
Expand Down Expand Up @@ -94,6 +91,7 @@ const config = {
format: 'npm run format',
lint: 'npm run lint',
rollup: 'npx rollup -c',
'test-node': 'npx qunit test/node.js',
'browserstack-runner': 'node_modules/.bin/browserstack-runner --verbose'
}
}
Expand All @@ -110,7 +108,7 @@ module.exports = function (grunt) {
'exec:rollup',
'connect:build-qunit',
'qunit',
'nodeunit'
'exec:test-node'
])
grunt.registerTask('browserstack', [
'exec:rollup',
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -55,7 +55,6 @@
"grunt": "^1.0.4",
"grunt-compare-size": "^0.4.2",
"grunt-contrib-connect": "^3.0.0",
"grunt-contrib-nodeunit": "^5.0.0",
"grunt-contrib-qunit": "^7.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-exec": "^3.0.0",
Expand Down
51 changes: 23 additions & 28 deletions test/node.js
@@ -1,29 +1,24 @@
/* global QUnit */
/* eslint-env node */
exports.node = {
shouldLoadApi: function (test) {
test.expect(1)
const Cookies = require('../dist/js.cookie.min.js')
test.ok(!!Cookies.get, 'should load the Cookies API')
test.done()
},
shouldNotThrowErrorForSetCallInNode: function (test) {
test.expect(0)
const Cookies = require('../dist/js.cookie.min.js')
Cookies.set('anything')
Cookies.set('anything', { path: '' })
test.done()
},
shouldNotThrowErrorForGetCallInNode: function (test) {
test.expect(0)
const Cookies = require('../dist/js.cookie.min.js')
Cookies.get('anything')
test.done()
},
shouldNotThrowErrorForRemoveCallInNode: function (test) {
test.expect(0)
const Cookies = require('../dist/js.cookie.min.js')
Cookies.remove('anything')
Cookies.remove('anything', { path: '' })
test.done()
}
}
const Cookies = require('../dist/js.cookie.min.js')

QUnit.test('api', (assert) => {
assert.ok(Cookies.get, 'get() expected to be defined')
assert.ok(Cookies.set, 'set() expected to be defined')
assert.ok(Cookies.remove, 'remove() expected to be defined')
})

QUnit.test('noop get', (assert) => {
assert.expect(0)
Cookies.get('anything')
})

QUnit.test('noop set', (assert) => {
assert.expect(0)
Cookies.set('anything')
})

QUnit.test('noop remove', (assert) => {
assert.expect(0)
Cookies.remove('anything')
})

0 comments on commit aecb4b3

Please sign in to comment.