feat(test_lib): change test_lib.dart to structurally compare objects
This commit is contained in:
parent
9bd65abb32
commit
acd7035347
|
@ -7,4 +7,4 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test_lib:
|
test_lib:
|
||||||
path: ../test_lib
|
path: ../test_lib
|
||||||
guinness: ">=0.1.5 <0.2.0"
|
guinness: ">=0.1.16 <0.2.0"
|
|
@ -11,4 +11,4 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test_lib:
|
test_lib:
|
||||||
path: ../test_lib
|
path: ../test_lib
|
||||||
guinness: ">=0.1.5 <0.2.0"
|
guinness: ">=0.1.16 <0.2.0"
|
|
@ -7,4 +7,4 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test_lib:
|
test_lib:
|
||||||
path: ../test_lib
|
path: ../test_lib
|
||||||
guinness: ">=0.1.5 <0.2.0"
|
guinness: ">=0.1.16 <0.2.0"
|
|
@ -7,4 +7,4 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test_lib:
|
test_lib:
|
||||||
path: ../test_lib
|
path: ../test_lib
|
||||||
guinness: ">=0.1.5 <0.2.0"
|
guinness: ">=0.1.16 <0.2.0"
|
|
@ -4,4 +4,4 @@ environment:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test_lib:
|
test_lib:
|
||||||
path: ../test_lib
|
path: ../test_lib
|
||||||
guinness: ">=0.1.5 <0.2.0"
|
guinness: ">=0.1.16 <0.2.0"
|
|
@ -3,4 +3,4 @@ environment:
|
||||||
sdk: '>=1.4.0'
|
sdk: '>=1.4.0'
|
||||||
dependencies:
|
dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
guinness: ">=0.1.5 <0.2.0"
|
guinness: ">=0.1.16 <0.2.0"
|
|
@ -15,11 +15,20 @@ Expect expect(actual, [matcher]) {
|
||||||
class Expect extends gns.Expect {
|
class Expect extends gns.Expect {
|
||||||
Expect(actual) : super(actual);
|
Expect(actual) : super(actual);
|
||||||
|
|
||||||
|
NotExpect get not => new NotExpect(actual);
|
||||||
|
|
||||||
|
void toEqual(expected) => toHaveSameProps(expected);
|
||||||
void toThrowError([message=""]) => this.toThrowWith(message: message);
|
void toThrowError([message=""]) => this.toThrowWith(message: message);
|
||||||
void toBePromise() => _expect(actual is Future, equals(true));
|
void toBePromise() => _expect(actual is Future, equals(true));
|
||||||
Function get _expect => gns.guinness.matchers.expect;
|
Function get _expect => gns.guinness.matchers.expect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NotExpect extends gns.NotExpect {
|
||||||
|
NotExpect(actual) : super(actual);
|
||||||
|
|
||||||
|
void toEqual(expected) => toHaveSameProps(expected);
|
||||||
|
}
|
||||||
|
|
||||||
it(name, fn) {
|
it(name, fn) {
|
||||||
gns.it(name, _handleAsync(fn));
|
gns.it(name, _handleAsync(fn));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import {describe, it, iit, expect} from 'test_lib/test_lib';
|
||||||
|
|
||||||
|
class TestObj {
|
||||||
|
constructor(prop) {
|
||||||
|
this.prop = prop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function main() {
|
||||||
|
describe("test_lib", function () {
|
||||||
|
describe("equality", function () {
|
||||||
|
it("should structurally compare objects", function () {
|
||||||
|
var expected = new TestObj(new TestObj({"one" : [1,2]}));
|
||||||
|
var actual = new TestObj(new TestObj({"one" : [1,2]}));
|
||||||
|
var falseActual = new TestObj(new TestObj({"one" : [1,3]}));
|
||||||
|
|
||||||
|
expect(actual).toEqual(expected);
|
||||||
|
expect(falseActual).not.toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -16,4 +16,4 @@ dependencies:
|
||||||
path: build/dart/change_detection
|
path: build/dart/change_detection
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
guinness: ">=0.1.5 <0.2.0"
|
guinness: ">=0.1.16 <0.2.0"
|
Loading…
Reference in New Issue