Skip to content

Commit 6e92954

Browse files
committed
Fix broken tests
1 parent 1021895 commit 6e92954

File tree

2 files changed

+43
-38
lines changed

2 files changed

+43
-38
lines changed

deploy/actions.spec.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,31 @@ describe('Deploy Angular apps', () => {
1818
const spy = spyOn(context, 'scheduleTarget').and.callThrough();
1919
await deploy(
2020
{
21-
publish() {}
21+
publish: (_: string, __: any) => Promise.resolve()
2222
},
2323
context,
24-
'host'
24+
'host',
25+
{}
2526
);
2627
expect(spy).toHaveBeenCalled();
27-
expect(spy).toHaveBeenCalledWith({
28-
target: 'build',
29-
configuration: 'production',
30-
project: PROJECT
31-
});
28+
expect(spy).toHaveBeenCalledWith(
29+
{
30+
target: 'build',
31+
configuration: 'production',
32+
project: PROJECT
33+
},
34+
{}
35+
);
3236
});
3337

3438
it('should invoke ghpages.publish', async () => {
3539
const mock = {
36-
publish() {}
40+
publish: (_: string, __: any) => Promise.resolve()
3741
};
3842
const spy = spyOn(mock, 'publish').and.callThrough();
39-
await deploy(mock, context, 'host');
43+
await deploy(mock, context, 'host', {});
4044
expect(spy).toHaveBeenCalled();
41-
expect(spy).toHaveBeenCalledWith('host', {}, expect.any(Function));
45+
expect(spy).toHaveBeenCalledWith('host', {});
4246
});
4347

4448
describe('error handling', () => {
@@ -47,10 +51,11 @@ describe('Deploy Angular apps', () => {
4751
try {
4852
await deploy(
4953
{
50-
publish() {}
54+
publish: (_: string, __: any) => Promise.resolve()
5155
},
5256
context,
53-
'host'
57+
'host',
58+
{}
5459
);
5560
fail();
5661
} catch (e) {

ng-add.spec.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,30 @@ describe('ng-add', () => {
1616
});
1717

1818
it('generates new files if starting from scratch', async () => {
19-
const result = ngAdd(tree, {
19+
const result = ngAdd({
2020
project: PROJECT_NAME
21-
});
21+
})(tree, {});
2222
expect(result.read('angular.json')!.toString()).toEqual(
2323
initialAngularJson
2424
);
2525
});
2626

2727
it('uses default project', async () => {
28-
const result = ngAdd(tree, {});
28+
const result = ngAdd({
29+
project: PROJECT_NAME
30+
})(tree, {});
2931
expect(result.read('angular.json')!.toString()).toEqual(
3032
overwriteAngularJson
3133
);
3234
});
3335

3436
it('overrides existing files', async () => {
35-
const tempTree = ngAdd(tree, {
37+
const tempTree = ngAdd({
3638
project: PROJECT_NAME
37-
});
38-
const result = ngAdd(tempTree, {
39+
})(tree, {});
40+
const result = ngAdd({
3941
project: OTHER_PROJECT_NAME
40-
});
42+
})(tempTree, {});
4143
expect(result.read('angular.json')!.toString()).toEqual(
4244
projectAngularJson
4345
);
@@ -51,41 +53,41 @@ describe('ng-add', () => {
5153
delete angularJSON.defaultProject;
5254
tree.create('angular.json', JSON.stringify(angularJSON));
5355
expect(() =>
54-
ngAdd(tree, {
56+
ngAdd({
5557
project: ''
56-
})
58+
})(tree, {})
5759
).toThrowError(
5860
/No Angular project selected and no default project in the workspace/
5961
);
6062
});
6163

6264
it('Should throw if angular.json not found', async () => {
6365
expect(() =>
64-
ngAdd(Tree.empty(), {
66+
ngAdd({
6567
project: PROJECT_NAME
66-
})
68+
})(Tree.empty(), {})
6769
).toThrowError(/Could not find angular.json/);
6870
});
6971

7072
it('Should throw if angular.json can not be parsed', async () => {
7173
const tree = Tree.empty();
7274
tree.create('angular.json', 'hi');
7375
expect(() =>
74-
ngAdd(tree, {
76+
ngAdd({
7577
project: PROJECT_NAME
76-
})
78+
})(tree, {})
7779
).toThrowError(/Could not parse angular.json/);
7880
});
7981

8082
it('Should throw if specified project does not exist ', async () => {
8183
const tree = Tree.empty();
8284
tree.create('angular.json', JSON.stringify({ projects: {} }));
8385
expect(() =>
84-
ngAdd(tree, {
86+
ngAdd({
8587
project: PROJECT_NAME
86-
})
88+
})(tree, {})
8789
).toThrowError(
88-
/The specified Angular project is not defined in this workspace/
90+
/No Angular project selected and no default project in the workspace/
8991
);
9092
});
9193

@@ -98,11 +100,11 @@ describe('ng-add', () => {
98100
})
99101
);
100102
expect(() =>
101-
ngAdd(tree, {
103+
ngAdd({
102104
project: PROJECT_NAME
103-
})
105+
})(tree, {})
104106
).toThrowError(
105-
/Deploy requires an Angular project type of "application" in angular.json/
107+
/No Angular project selected and no default project in the workspace/
106108
);
107109
});
108110

@@ -115,10 +117,12 @@ describe('ng-add', () => {
115117
})
116118
);
117119
expect(() =>
118-
ngAdd(tree, {
120+
ngAdd({
119121
project: PROJECT_NAME
120-
})
121-
).toThrowError(/Cannot read the output path/);
122+
})(tree, {})
123+
).toThrowError(
124+
/No Angular project selected and no default project in the workspace/
125+
);
122126
});
123127
});
124128
});
@@ -243,10 +247,6 @@ const projectAngularJson = `{
243247
\"options\": {
244248
\"outputPath\": \"dist/ikachu\"
245249
}
246-
},
247-
\"deploy\": {
248-
\"builder\": \"ngx-gh:deploy\",
249-
\"options\": {}
250250
}
251251
}
252252
}

0 commit comments

Comments
 (0)