-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first class Javascript/Typescript support to the Mill build tool (#…
- Loading branch information
1 parent
56befd8
commit 7197505
Showing
11 changed files
with
291 additions
and
14 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
example/javascriptlib/testing/1-test-suite/baz/src/calculator.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,11 @@ | ||
export class Calculator { | ||
add(a, b) { | ||
return a + b; | ||
} | ||
divide(a, b) { | ||
if (b === 0) { | ||
throw new Error("Division by zero is not allowed"); | ||
} | ||
return a / b; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
example/javascriptlib/testing/1-test-suite/baz/src/calculator.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,12 @@ | ||
export class Calculator { | ||
add(a: number, b: number): number { | ||
return a + b; | ||
} | ||
|
||
divide(a: number, b: number): number { | ||
if (b === 0) { | ||
throw new Error("Division by zero is not allowed"); | ||
} | ||
return a / b; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
example/javascriptlib/testing/1-test-suite/baz/test/src/baz/calculator.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,24 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { Calculator } from 'baz/calculator'; | ||
describe('Calculator', () => { | ||
const calculator = new Calculator(); | ||
describe('Addition', () => { | ||
test('should return the sum of two numbers', () => { | ||
const result = calculator.add(2, 3); | ||
expect(result).toEqual(5); | ||
}); | ||
test('should return the correct sum for negative numbers', () => { | ||
const result = calculator.add(-2, -3); | ||
expect(result).toEqual(-5); | ||
}); | ||
}); | ||
describe('Division', () => { | ||
test('should return the quotient of two numbers', () => { | ||
const result = calculator.divide(6, 3); | ||
expect(result).toEqual(2); | ||
}); | ||
it('should throw an error when dividing by zero', () => { | ||
expect(() => calculator.divide(6, 0)).toThrow("Division by zero is not allowed"); | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
example/javascriptlib/testing/1-test-suite/baz/test/src/baz/calculator.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,28 @@ | ||
import { Calculator } from 'baz/calculator'; | ||
|
||
describe('Calculator', () => { | ||
const calculator = new Calculator(); | ||
|
||
describe('Addition', () => { | ||
test('should return the sum of two numbers', () => { | ||
const result = calculator.add(2, 3); | ||
expect(result).toEqual(5); | ||
}); | ||
|
||
test('should return the correct sum for negative numbers', () => { | ||
const result = calculator.add(-2, -3); | ||
expect(result).toEqual(-5); | ||
}); | ||
}); | ||
|
||
describe('Division', () => { | ||
test('should return the quotient of two numbers', () => { | ||
const result = calculator.divide(6, 3); | ||
expect(result).toEqual(2); | ||
}); | ||
|
||
it('should throw an error when dividing by zero', () => { | ||
expect(() => calculator.divide(6, 0)).toThrow("Division by zero is not allowed"); | ||
}); | ||
}); | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
example/javascriptlib/testing/1-test-suite/qux/src/calculator.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,11 @@ | ||
export class Calculator { | ||
add(a, b) { | ||
return a + b; | ||
} | ||
divide(a, b) { | ||
if (b === 0) { | ||
throw new Error("Division by zero is not allowed"); | ||
} | ||
return a / b; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
example/javascriptlib/testing/1-test-suite/qux/src/calculator.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,12 @@ | ||
export class Calculator { | ||
add(a: number, b: number): number { | ||
return a + b; | ||
} | ||
|
||
divide(a: number, b: number): number { | ||
if (b === 0) { | ||
throw new Error("Division by zero is not allowed"); | ||
} | ||
return a / b; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
example/javascriptlib/testing/1-test-suite/qux/test/src/calculator.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,28 @@ | ||
import { Calculator } from 'qux/calculator'; | ||
|
||
describe('Calculator', () => { | ||
const calculator = new Calculator(); | ||
|
||
describe('Addition', () => { | ||
it('should return the sum of two numbers', () => { | ||
const result = calculator.add(2, 3); | ||
expect(result).toEqual(5); | ||
}); | ||
|
||
it('should return the correct sum for negative numbers', () => { | ||
const result = calculator.add(-2, -3); | ||
expect(result).toEqual(-5); | ||
}); | ||
}); | ||
|
||
describe('Division', () => { | ||
it('should return the quotient of two numbers', () => { | ||
const result = calculator.divide(6, 3); | ||
expect(result).toEqual(2); | ||
}); | ||
|
||
it('should throw an error when dividing by zero', () => { | ||
expect(() => calculator.divide(6, 0)).toThrowError("Division by zero is not allowed"); | ||
}); | ||
}); | ||
}); |
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,12 @@ | ||
/// <reference types="vitest" /> | ||
import { defineConfig } from 'vite'; | ||
import tsconfigPaths from 'vite-tsconfig-paths'; | ||
|
||
export default defineConfig({ | ||
plugins: [tsconfigPaths()], | ||
test: { | ||
globals: true, | ||
environment: 'node', | ||
include: ['**/**/*.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
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