-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(umi-build-dva): ignore test files as model, Close umijs#419
- Loading branch information
Showing
19 changed files
with
120 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
2 changes: 2 additions & 0 deletions
2
packages/umi-plugin-dva/src/fixtures/getModel/ignore-d-ts/models/b.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
Empty file.
2 changes: 2 additions & 0 deletions
2
packages/umi-plugin-dva/src/fixtures/getModel/ignore-test-files/models/b.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
packages/umi-plugin-dva/src/fixtures/getModel/ignore-test-files/models/c.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
packages/umi-plugin-dva/src/fixtures/getModel/ignore-test-files/models/d.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
packages/umi-plugin-dva/src/fixtures/getModel/ignore-test-files/models/e.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { join } from 'path'; | ||
import { getModel } from './index'; | ||
|
||
const api = { | ||
service: { | ||
config: { | ||
singular: false, | ||
}, | ||
}, | ||
utils: { | ||
winPath(p) { | ||
return p; | ||
}, | ||
}, | ||
}; | ||
|
||
const base = join(__dirname, 'fixtures', 'getModel'); | ||
|
||
function normalizeModels(models, base) { | ||
return models.map(model => model.replace(base, '$CWD$')); | ||
} | ||
|
||
describe('umi-plugin-dva', () => { | ||
it('getModel with model.js', () => { | ||
const dir = join(base, 'model'); | ||
const models = normalizeModels(getModel(dir, api), dir); | ||
expect(models).toEqual(['$CWD$/model.js']); | ||
}); | ||
|
||
it('getModel with models directory', () => { | ||
const dir = join(base, 'models'); | ||
const models = normalizeModels(getModel(dir, api), dir); | ||
expect(models).toEqual([ | ||
'$CWD$/models/a.js', | ||
'$CWD$/models/a.jsx', | ||
'$CWD$/models/a.ts', | ||
'$CWD$/models/a.tsx', | ||
]); | ||
}); | ||
|
||
it('getModel with model directory and singular', () => { | ||
const dir = join(base, 'models-with-singular'); | ||
const models = normalizeModels( | ||
getModel(dir, { | ||
...api, | ||
service: { config: { singular: true } }, | ||
}), | ||
dir, | ||
); | ||
expect(models).toEqual(['$CWD$/model/a.js']); | ||
}); | ||
|
||
it('getModel ignore d.ts', () => { | ||
const dir = join(base, 'ignore-d-ts'); | ||
const models = normalizeModels(getModel(dir, api), dir); | ||
expect(models).toEqual(['$CWD$/models/a.ts']); | ||
}); | ||
|
||
it('getModel ignore test files', () => { | ||
const dir = join(base, 'ignore-test-files'); | ||
const models = normalizeModels(getModel(dir, api), dir); | ||
expect(models).toEqual(['$CWD$/models/a.ts']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters