1 | /// <reference types="node" />
|
2 |
|
3 | import assert = require("assert");
|
4 |
|
5 | declare module "assert" {
|
6 | /**
|
7 | * Assert that a file exists or that each files in the array exists
|
8 | * @param path path to a file or an array of paths to files
|
9 | * @example
|
10 | * assert.file('templates/user.hbs');
|
11 | * assert.noFile(['templates/user.hbs', 'templates/user/edit.hbs']);
|
12 | */
|
13 | function file(path: string | string[]): void;
|
14 |
|
15 | /**
|
16 | * Assert that a file doesn't exist
|
17 | * @param file path to a file
|
18 | * @example
|
19 | * assert.noFile('templates/user.hbs');
|
20 | * assert.noFile(['templates/user.hbs', 'templates/user/edit.hbs']);
|
21 | */
|
22 | function noFile(file: string | string[]): void;
|
23 |
|
24 | /**
|
25 | * Assert that a file's content matches a regex or string
|
26 | * @param file path to a file
|
27 | * @param reg regex / string that will be used to search the file
|
28 | * @example
|
29 | * assert.fileContent('models/user.js', /App\.User = DS\.Model\.extend/);
|
30 | * assert.fileContent('models/user.js', 'App.User = DS.Model.extend');
|
31 | */
|
32 | function fileContent(file: string | string[], reg: string | RegExp): void;
|
33 |
|
34 | /**
|
35 | * Assert that each file in an array of file-regex pairs matches its corresponding regex
|
36 | * @param pairs an array of arrays, where each subarray is a [String, RegExp] pair
|
37 | * @example
|
38 | * var arg = [
|
39 | * [ 'models/user.js', /App\.User = DS\.Model\.extend/ ],
|
40 | * [ 'controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/ ]
|
41 | * ]
|
42 | * assert.fileContent(arg);
|
43 | */
|
44 | function fileContent(pairs: Array<[string, RegExp]>): void;
|
45 |
|
46 | /**
|
47 | * Assert that a file's content is the same as the given string
|
48 | * @param file path to a file
|
49 | * @param expectedContent the expected content of the file
|
50 | * @example
|
51 | * assert.equalsFileContent(
|
52 | * 'data.js',
|
53 | * 'const greeting = "Hello";\nexport default { greeting }'
|
54 | * );
|
55 | */
|
56 | function equalsFileContent(file: string, expectedContent: string): void;
|
57 |
|
58 | /**
|
59 | * Assert that each file in an array of file-string pairs equals its corresponding string
|
60 | * @param pairs an array of arrays, where each subarray is a [String, String] pair
|
61 | * @example
|
62 | * assert.equalsFileContent([
|
63 | * ['data.js', 'const greeting = "Hello";\nexport default { greeting }'],
|
64 | * ['user.js', 'export default {\n name: 'Coleman',\n age: 0\n}']
|
65 | * ]);
|
66 | */
|
67 | function equalsFileContent(pairs: Array<[string, string]>): void;
|
68 |
|
69 | /**
|
70 | * Assert that a file's content does not match a regex / string
|
71 | * @param file path to a file
|
72 | * @param reg regex / string that will be used to search the file
|
73 | * @example
|
74 | * assert.noFileContent('models/user.js', /App\.User = DS\.Model\.extend/);
|
75 | * assert.noFileContent('models/user.js', 'App.User = DS.Model.extend');
|
76 | */
|
77 | function noFileContent(file: string | string[], reg: RegExp | string): void;
|
78 |
|
79 | /**
|
80 | * Assert that each file in an array of file-regex pairs does not match its corresponding regex
|
81 | * @param pairs an array of arrays, where each subarray is a [String, RegExp] pair
|
82 | * var arg = [
|
83 | * [ 'models/user.js', /App\.User \ DS\.Model\.extend/ ],
|
84 | * [ 'controllers/user.js', /App\.UserController = Ember\.ObjectController\.extend/ ]
|
85 | * ]
|
86 | * assert.noFileContent(arg);
|
87 | */
|
88 | function noFileContent(pairs: Array<[string, RegExp]>): void;
|
89 |
|
90 | /**
|
91 | * Assert that two strings are equal after standardization of newlines
|
92 | * @param value a string
|
93 | * @param expected the expected value of the string
|
94 | * @example
|
95 | * assert.textEqual('I have a yellow cat', 'I have a yellow cat');
|
96 | */
|
97 | function textEqual(value: string, expected: string): void;
|
98 |
|
99 | /**
|
100 | * Assert an Object implements an interface
|
101 | * @param subject subject implementing the façade
|
102 | * @param methods a façace, hash or array of keys to be implemented
|
103 | */
|
104 | function implement(subject: object, methods: object | string[]): void;
|
105 |
|
106 | /**
|
107 | * Assert an Object doesn't implements any method of an interface
|
108 | * @param subject subject not implementing the methods
|
109 | * @param methods hash or array of method names to be implemented
|
110 | */
|
111 | function notImplement(subject: object, methods: object | string[]): void;
|
112 |
|
113 | /**
|
114 | * Assert an object contains the provided keys
|
115 | * @param obj Object that should match the given pattern
|
116 | * @param content An object of key/values the object should contains
|
117 | */
|
118 | function objectContent(obj: object, content: object): void;
|
119 |
|
120 | /**
|
121 | * Assert an object does not contain the provided keys
|
122 | * @param obj Object that should not match the given pattern
|
123 | * @param content An object of key/values the object should not contain
|
124 | */
|
125 | function noObjectContent(obj: object, content: object): void;
|
126 |
|
127 | /**
|
128 | * Assert a JSON file contains the provided keys
|
129 | * @param filename
|
130 | * @param content An object of key/values the file should contains
|
131 | */
|
132 | function JSONFileContent(filename: string, content: object): void;
|
133 |
|
134 | /**
|
135 | * @see JSONFileContent
|
136 | */
|
137 | function jsonFileContent(filename: string, content: object): void;
|
138 |
|
139 | /**
|
140 | * Assert a JSON file does not contain the provided keys
|
141 | * @param filename
|
142 | * @param content An object of key/values the file should not contain
|
143 | */
|
144 | function noJSONFileContent(filename: string, content: object): void;
|
145 |
|
146 | /**
|
147 | * @see noJSONFileContent
|
148 | */
|
149 | function noJsonFileContent(filename: string, content: object): void;
|
150 | }
|
151 |
|
152 | export = assert;
|