Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Jan 4, 2025
1 parent 304244b commit bfa9bdd
Show file tree
Hide file tree
Showing 18 changed files with 1,231 additions and 1,135 deletions.
46 changes: 23 additions & 23 deletions test/unit/assert/empty_test.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
let expect;
let expect
import('chai').then(chai => {
expect = chai.expect;
});
expect = chai.expect
})

const { Assertion } = require('../../../lib/assert/empty');
const AssertionError = require('../../../lib/assert/error');
const { Assertion } = require('../../../lib/assert/empty')
const AssertionError = require('../../../lib/assert/error')

let empty;
let empty

describe('empty assertion', () => {
beforeEach(() => {
empty = new Assertion({ subject: 'web page' });
});
empty = new Assertion({ subject: 'web page' })
})

it('should check for something to be empty', () => {
empty.assert(null);
expect(() => empty.negate(null)).to.throw(AssertionError);
});
empty.assert(null)
expect(() => empty.negate(null)).to.throw(AssertionError)
})

it('should check for something not to be empty', () => {
empty.negate('something');
expect(() => empty.assert('something')).to.throw(AssertionError);
});
empty.negate('something')
expect(() => empty.assert('something')).to.throw(AssertionError)
})

it('should provide nice assert error message', () => {
empty.params.value = '/nothing';
const err = empty.getFailedAssertion();
expect(err.inspect()).to.equal("expected web page '/nothing' to be empty");
});
empty.params.value = '/nothing'
const err = empty.getFailedAssertion()
expect(err.inspect()).to.equal("expected web page '/nothing' to be empty")
})

it('should provide nice negate error message', () => {
empty.params.value = '/nothing';
const err = empty.getFailedNegation();
expect(err.inspect()).to.equal("expected web page '/nothing' not to be empty");
});
});
empty.params.value = '/nothing'
const err = empty.getFailedNegation()
expect(err.inspect()).to.equal("expected web page '/nothing' not to be empty")
})
})
50 changes: 25 additions & 25 deletions test/unit/assert/equal_test.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
let expect;
let expect
import('chai').then(chai => {
expect = chai.expect;
});
expect = chai.expect
})

const { Assertion } = require('../../../lib/assert/equal');
const AssertionError = require('../../../lib/assert/error');
const { Assertion } = require('../../../lib/assert/equal')
const AssertionError = require('../../../lib/assert/error')

let equal;
let equal

describe('equal assertion', () => {
beforeEach(() => {
equal = new Assertion({ jar: 'contents of webpage' });
});
equal = new Assertion({ jar: 'contents of webpage' })
})

it('should check for equality', () => {
equal.assert('hello', 'hello');
expect(() => equal.negate('hello', 'hello')).to.throw(AssertionError);
});
equal.assert('hello', 'hello')
expect(() => equal.negate('hello', 'hello')).to.throw(AssertionError)
})

it('should check for something not to be equal', () => {
equal.negate('hello', 'hi');
expect(() => equal.assert('hello', 'hi')).to.throw(AssertionError);
});
equal.negate('hello', 'hi')
expect(() => equal.assert('hello', 'hi')).to.throw(AssertionError)
})

it('should provide nice assert error message', () => {
equal.params.expected = 'hello';
equal.params.actual = 'hi';
const err = equal.getFailedAssertion();
expect(err.inspect()).to.equal('expected contents of webpage "hello" to equal "hi"');
});
equal.params.expected = 'hello'
equal.params.actual = 'hi'
const err = equal.getFailedAssertion()
expect(err.inspect()).to.equal('expected contents of webpage "hello" to equal "hi"')
})

it('should provide nice negate error message', () => {
equal.params.expected = 'hello';
equal.params.actual = 'hello';
const err = equal.getFailedNegation();
expect(err.inspect()).to.equal('expected contents of webpage "hello" not to equal "hello"');
});
});
equal.params.expected = 'hello'
equal.params.actual = 'hello'
const err = equal.getFailedNegation()
expect(err.inspect()).to.equal('expected contents of webpage "hello" not to equal "hello"')
})
})
50 changes: 25 additions & 25 deletions test/unit/assert/include_test.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
let expect;
let expect
import('chai').then(chai => {
expect = chai.expect;
});
expect = chai.expect
})

const Assertion = require('../../../lib/assert/include').Assertion;
const AssertionError = require('../../../lib/assert/error');
const Assertion = require('../../../lib/assert/include').Assertion
const AssertionError = require('../../../lib/assert/error')

let equal;
let equal

describe('equal assertion', () => {
beforeEach(() => {
equal = new Assertion({ jar: 'contents of webpage' });
});
equal = new Assertion({ jar: 'contents of webpage' })
})

it('should check for inclusion', () => {
equal.assert('h', 'hello');
expect(() => equal.negate('h', 'hello')).to.throw(AssertionError);
});
equal.assert('h', 'hello')
expect(() => equal.negate('h', 'hello')).to.throw(AssertionError)
})

it('should check !include', () => {
equal.negate('x', 'hello');
expect(() => equal.assert('x', 'hello')).to.throw(AssertionError);
});
equal.negate('x', 'hello')
expect(() => equal.assert('x', 'hello')).to.throw(AssertionError)
})

it('should provide nice assert error message', () => {
equal.params.needle = 'hello';
equal.params.haystack = 'x';
const err = equal.getFailedAssertion();
expect(err.inspect()).to.equal('expected contents of webpage to include "hello"');
});
equal.params.needle = 'hello'
equal.params.haystack = 'x'
const err = equal.getFailedAssertion()
expect(err.inspect()).to.equal('expected contents of webpage to include "hello"')
})

it('should provide nice negate error message', () => {
equal.params.needle = 'hello';
equal.params.haystack = 'h';
const err = equal.getFailedNegation();
expect(err.inspect()).to.equal('expected contents of webpage not to include "hello"');
});
});
equal.params.needle = 'hello'
equal.params.haystack = 'h'
const err = equal.getFailedNegation()
expect(err.inspect()).to.equal('expected contents of webpage not to include "hello"')
})
})
Loading

0 comments on commit bfa9bdd

Please sign in to comment.