1 | const metadata = require("../lib/mixins/metadata");
|
2 |
|
3 | const createThis = () => {
|
4 | var self = {
|
5 | _root: {
|
6 | data: {}
|
7 | }
|
8 | };
|
9 |
|
10 | self.write = jest.fn(data => {
|
11 | self.output = data;
|
12 | });
|
13 |
|
14 | self.end = jest.fn();
|
15 |
|
16 | self.ref = jest.fn(obj => {
|
17 | var methods = {
|
18 | write: self.write,
|
19 | end: self.end
|
20 | };
|
21 | return Object.assign({ data: obj }, methods);
|
22 | });
|
23 |
|
24 | return self;
|
25 | };
|
26 |
|
27 | describe("metadata mixin", () => {
|
28 | it("should add xml stream to document", () => {
|
29 | var self = createThis();
|
30 |
|
31 | metadata.setMetadata.call(self, {});
|
32 |
|
33 | expect(self._root.data.Metadata).toBeDefined();
|
34 | expect(self.output.length).toBeGreaterThan(0);
|
35 | expect(self.ref.mock.calls.length).toBe(1);
|
36 | expect(self.write.mock.calls.length).toBe(1);
|
37 | expect(self.end.mock.calls.length).toBe(1);
|
38 | });
|
39 | });
|