-
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.
- Loading branch information
Showing
21 changed files
with
329 additions
and
329 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import "/src/global.scss"; | ||
import '/src/global.scss' | ||
|
||
import { createApp } from "vue"; | ||
import { createApp } from 'vue' | ||
|
||
import ExampleApp from "./ExampleApp.vue"; | ||
import ExampleApp from './ExampleApp.vue' | ||
|
||
createApp(ExampleApp).mount("#app"); | ||
createApp(ExampleApp).mount('#app') |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import vue from "@vitejs/plugin-vue"; | ||
import { defineConfig } from "vite"; | ||
import vueExamples from "vite-plugin-vue-examples"; | ||
import vue from '@vitejs/plugin-vue' | ||
import { defineConfig } from 'vite' | ||
import vueExamples from 'vite-plugin-vue-examples' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
vue(), | ||
vueExamples({ globalStylesheetPaths: ["/src/global.scss"] }), | ||
vueExamples({ globalStylesheetPaths: ['/src/global.scss'] }), | ||
], | ||
}); | ||
}) |
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 |
---|---|---|
@@ -1,48 +1,48 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { describe, expect, it } from 'vitest' | ||
|
||
import { examplesAppMainFileTransformer } from "./examples-app-main-file-transformer"; | ||
import { examplesAppMainFileTransformer } from './examples-app-main-file-transformer' | ||
|
||
describe("examplesAppMainFileTransformer", () => { | ||
describe("matchesId", () => { | ||
it("should match id", () => { | ||
const examplesAppDir = "/examplesApp"; | ||
const transformer = examplesAppMainFileTransformer(examplesAppDir); | ||
describe('examplesAppMainFileTransformer', () => { | ||
describe('matchesId', () => { | ||
it('should match id', () => { | ||
const examplesAppDir = '/examplesApp' | ||
const transformer = examplesAppMainFileTransformer(examplesAppDir) | ||
|
||
const matches = transformer.matchesId(`${examplesAppDir}/main.ts`); | ||
const matches = transformer.matchesId(`${examplesAppDir}/main.ts`) | ||
|
||
expect(matches).toBe(true); | ||
}); | ||
it("should match id when query string is added", () => { | ||
const examplesAppDir = "/examplesApp"; | ||
const transformer = examplesAppMainFileTransformer(examplesAppDir); | ||
expect(matches).toBe(true) | ||
}) | ||
it('should match id when query string is added', () => { | ||
const examplesAppDir = '/examplesApp' | ||
const transformer = examplesAppMainFileTransformer(examplesAppDir) | ||
|
||
const matches = transformer.matchesId(`${examplesAppDir}/main.ts?id=123`); | ||
const matches = transformer.matchesId(`${examplesAppDir}/main.ts?id=123`) | ||
|
||
expect(matches).toBe(true); | ||
}); | ||
it("should not match id for other file", () => { | ||
const examplesAppDir = "/examplesApp"; | ||
const transformer = examplesAppMainFileTransformer(examplesAppDir); | ||
expect(matches).toBe(true) | ||
}) | ||
it('should not match id for other file', () => { | ||
const examplesAppDir = '/examplesApp' | ||
const transformer = examplesAppMainFileTransformer(examplesAppDir) | ||
|
||
const matches = transformer.matchesId(`${examplesAppDir}/App.vue`); | ||
const matches = transformer.matchesId(`${examplesAppDir}/App.vue`) | ||
|
||
expect(matches).toBe(false); | ||
}); | ||
}); | ||
expect(matches).toBe(false) | ||
}) | ||
}) | ||
|
||
describe("addStyleSheet", () => { | ||
it("should add style sheets on top", () => { | ||
const transformer = examplesAppMainFileTransformer("any"); | ||
const stylesheetPaths = ["global.scss", "@dir/global.scss"]; | ||
describe('addStyleSheet', () => { | ||
it('should add style sheets on top', () => { | ||
const transformer = examplesAppMainFileTransformer('any') | ||
const stylesheetPaths = ['global.scss', '@dir/global.scss'] | ||
|
||
const transformedMainSource = transformer.addStyleSheet( | ||
"code", | ||
'code', | ||
stylesheetPaths, | ||
); | ||
) | ||
|
||
expect(transformedMainSource).toBe( | ||
`import 'global.scss'\nimport '@dir/global.scss'\ncode`, | ||
); | ||
}); | ||
}); | ||
}); | ||
) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
export const examplesAppMainFileTransformer = (examplesAppDir: string) => { | ||
const matchesId = (id: string) => { | ||
return id.startsWith(`${examplesAppDir}/main.ts`); | ||
}; | ||
return id.startsWith(`${examplesAppDir}/main.ts`) | ||
} | ||
|
||
const addStyleSheet = ( | ||
mainSource: string, | ||
stylesheetPaths: string[], | ||
): string => { | ||
let stylesheetImports = ""; | ||
let stylesheetImports = '' | ||
for (const stylesheetPath of stylesheetPaths) { | ||
stylesheetImports += `import '${stylesheetPath}'\n`; | ||
stylesheetImports += `import '${stylesheetPath}'\n` | ||
} | ||
return `${stylesheetImports}` + mainSource; | ||
}; | ||
return `${stylesheetImports}` + mainSource | ||
} | ||
|
||
return { | ||
matchesId, | ||
addStyleSheet, | ||
}; | ||
}; | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { Component } from "vue"; | ||
import { RouteRecordRaw } from "vue-router"; | ||
import { describe, expect, it } from 'vitest' | ||
import { Component } from 'vue' | ||
import { RouteRecordRaw } from 'vue-router' | ||
|
||
import { firstExamplePath } from "./first-example-path"; | ||
import { firstExamplePath } from './first-example-path' | ||
|
||
const dummyComponent: Component = {}; | ||
const dummyComponent: Component = {} | ||
|
||
describe("firstExamplePath", () => { | ||
it("should return path of example route", () => { | ||
describe('firstExamplePath', () => { | ||
it('should return path of example route', () => { | ||
const routeRecords: RouteRecordRaw[] = [ | ||
{ | ||
path: "group", | ||
children: [{ path: "NestedExample", component: dummyComponent }], | ||
path: 'group', | ||
children: [{ path: 'NestedExample', component: dummyComponent }], | ||
}, | ||
{ path: "Example", component: dummyComponent }, | ||
]; | ||
{ path: 'Example', component: dummyComponent }, | ||
] | ||
|
||
const path = firstExamplePath(routeRecords); | ||
const path = firstExamplePath(routeRecords) | ||
|
||
expect(path).toStrictEqual("Example"); | ||
}); | ||
expect(path).toStrictEqual('Example') | ||
}) | ||
|
||
it("should return complete path to example in group when no example is found in root level", () => { | ||
it('should return complete path to example in group when no example is found in root level', () => { | ||
const routeRecords: RouteRecordRaw[] = [ | ||
{ | ||
path: "group", | ||
children: [{ path: "NestedExample", component: dummyComponent }], | ||
path: 'group', | ||
children: [{ path: 'NestedExample', component: dummyComponent }], | ||
}, | ||
]; | ||
] | ||
|
||
const path = firstExamplePath(routeRecords); | ||
const path = firstExamplePath(routeRecords) | ||
|
||
expect(path).toStrictEqual("group/NestedExample"); | ||
}); | ||
expect(path).toStrictEqual('group/NestedExample') | ||
}) | ||
|
||
it("should return empty path when no examples found", () => { | ||
const routeRecords: RouteRecordRaw[] = [{ path: "group", children: [] }]; | ||
it('should return empty path when no examples found', () => { | ||
const routeRecords: RouteRecordRaw[] = [{ path: 'group', children: [] }] | ||
|
||
const path = firstExamplePath(routeRecords); | ||
const path = firstExamplePath(routeRecords) | ||
|
||
expect(path).toStrictEqual(""); | ||
}); | ||
}); | ||
expect(path).toStrictEqual('') | ||
}) | ||
}) |
Oops, something went wrong.