Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
microshine committed Jul 31, 2018
1 parent 00d24a9 commit 329e306
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/collection.ts
@@ -1,5 +1,5 @@
import * as assert from "assert";
import { Collection } from "../";
import { Collection } from "../src";

describe("Collection", () => {

Expand Down
2 changes: 1 addition & 1 deletion test/convert.ts
@@ -1,5 +1,5 @@
import * as assert from "assert";
import { Convert } from "../";
import { Convert } from "../src";

describe("Convert", () => {

Expand Down
4 changes: 2 additions & 2 deletions test/converters.ts
@@ -1,6 +1,6 @@
import * as assert from "assert";
import { XmlAttribute, XmlElement, XmlObject } from "../";
import { XmlBase64Converter, XmlBooleanConverter, XmlNumberConverter } from "../";
import { XmlAttribute, XmlElement, XmlObject } from "../src";
import { XmlBase64Converter, XmlBooleanConverter, XmlNumberConverter } from "../src";

// const xmldom = require("xmldom-alpha");
// const DOMParser = xmldom.DOMParser;
Expand Down
2 changes: 1 addition & 1 deletion test/decorators.ts
@@ -1,5 +1,5 @@
import * as assert from "assert";
import { Parse, XmlAttribute, XmlBase64Converter, XmlChildElement, XmlCollection, XmlContent, XmlElement, XmlNumberConverter, XmlObject } from "../";
import { Parse, XmlAttribute, XmlBase64Converter, XmlChildElement, XmlCollection, XmlContent, XmlElement, XmlNumberConverter, XmlObject } from "../src";

// const xmldom = require("xmldom-alpha");
// const DOMParser = xmldom.DOMParser;
Expand Down
2 changes: 1 addition & 1 deletion test/error.ts
@@ -1,5 +1,5 @@
import * as assert from "assert";
import { XE, XmlError } from "../";
import { XE, XmlError } from "../src";

describe("Error", () => {

Expand Down
6 changes: 3 additions & 3 deletions test/get_load.ts
@@ -1,7 +1,7 @@
import * as assert from "assert";
import { XmlAttribute, XmlChildElement, XmlElement } from "../";
import { XmlCollection, XmlObject } from "../";
import { XmlNumberConverter } from "../";
import { XmlAttribute, XmlChildElement, XmlElement } from "../src";
import { XmlCollection, XmlObject } from "../src";
import { XmlNumberConverter } from "../src";

context("GetXml/LoadXml/HasChanged", () => {

Expand Down
2 changes: 1 addition & 1 deletion test/namespace_manager.ts
@@ -1,5 +1,5 @@
import * as assert from "assert";
import { NamespaceManager } from "../";
import { NamespaceManager } from "../src";

context("NamespaceManager", () => {

Expand Down
4 changes: 2 additions & 2 deletions test/object.ts
@@ -1,6 +1,6 @@
import * as assert from "assert";
import { XmlAttribute, XmlElement } from "../";
import { XmlObject } from "../";
import { XmlAttribute, XmlElement } from "../src";
import { XmlObject } from "../src";

context("XmlObject", () => {

Expand Down
2 changes: 1 addition & 1 deletion test/utils.ts
@@ -1,5 +1,5 @@
import * as assert from "assert";
import { assign, Parse, SelectNamespaces, SelectSingleNode, Stringify } from "../";
import { assign, Parse, SelectNamespaces, SelectSingleNode, Stringify } from "../src";

context("utils", () => {

Expand Down
35 changes: 34 additions & 1 deletion test/xml_collection.ts
@@ -1,5 +1,5 @@
import * as assert from "assert";
import { XmlAttribute, XmlCollection, XmlElement, XmlObject } from "../";
import { XmlAttribute, XmlCollection, XmlElement, XmlObject } from "../src";

context("XmlCollection", () => {
@XmlElement({
Expand All @@ -22,6 +22,7 @@ context("XmlCollection", () => {
@XmlElement({
localName: "children",
namespaceURI: "http://some.com",
parser: Child,
})
class Children extends XmlCollection<Child> {
}
Expand Down Expand Up @@ -144,4 +145,36 @@ context("XmlCollection", () => {
return item.Id === 1;
}), false);
});

context("HasChanged", () => {

it("Initialized empty collection is not changed", () => {
const col = new Children();
assert.equal(col.HasChanged(), false);
});

it("Update state on item adding", () => {
const col = new Children();
col.Add(new Child());
assert.equal(col.HasChanged(), true);
});

it("Update state on item removing", () => {
const col = new Children();
col.Add(new Child());
col.GetXml();
assert.equal(col.HasChanged(), false);
col.RemoveAt(0);
assert.equal(col.HasChanged(), true);
});

it("Set unchanged state for loaded XML", () => {
const xml = `<children xmlns="http://some.com"><child id="0"/><child id="1"/></children>`;
const col = new Children();
col.LoadXml(xml);
assert.equal(col.HasChanged(), false);
assert.equal(col.Item(0)!.HasChanged(), false);
});

});
});

0 comments on commit 329e306

Please sign in to comment.