Skip to content

Commit

Permalink
test(KTL-1189); fix naming for webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
zoobestik committed Oct 17, 2023
1 parent 71b789b commit 34cede6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
42 changes: 35 additions & 7 deletions tests/crosslink.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import { promises as fs } from 'fs';
import { decompressFromBase64 } from 'lz-string';
import {expect, test} from '@playwright/test';
import {promises as fs} from 'fs';
import {decompressFromBase64} from 'lz-string';

const prefix = 'https://play.kotlinlang.org/editor/v1/' as const;

Expand All @@ -14,10 +14,10 @@ test.describe('crosslink: library', () => {

expect(typeof generateCrosslink).toEqual('function');

// Pass just code
// Pass just codeWithSample
checkLink(generateCrosslink('simple'), { code: 'simple' });

// Pass platforms with code
// Pass platforms with codeWithSample
checkLink(generateCrosslink('platform', { targetPlatform: 'JAVA' }), {
code: 'platform',
targetPlatform: 'JAVA',
Expand All @@ -28,16 +28,44 @@ test.describe('crosslink: library', () => {
generateCrosslink('platform', { targetPlatform: 'NOT_A_PLATFORM' }),
).toThrow();

// Pass compilerVersion with code
// Pass compilerVersion with codeWithSample
checkLink(generateCrosslink('version', { compilerVersion: '1.5.21' }), {
code: 'version',
compilerVersion: '1.5.21',
});

// Pass random with code
// Pass random with codeWithSample
checkLink(generateCrosslink('random', { randomProperty: '1.5.21' }), {
code: 'random',
});

//language=kotlin
const codeWithSample = `fun main(args: Array<String>) {
//sampleStart
val (name, value) = Pair("Kitty", "Kiss")
println(name)
println(value)
//sampleEnd
}`;

checkLink(generateCrosslink(codeWithSample), {
//language=text
code: `fun main(args: Array<String>) {
${' '}
val (name, value) = Pair("Kitty", "Kiss")
println(name)
println(value)
${' '}
}`
});

//language=text
const codeWithMark = `fun containsEven(collection: Collection<Int>): Boolean = collection.any {[mark]TODO()[/mark]}`;

checkLink(generateCrosslink(codeWithMark), {
//language=kotlin
code: `fun containsEven(collection: Collection<Int>): Boolean = collection.any {TODO()}`
});
});

test('definition', async () => {
Expand Down
6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = (params = {}) => {
],
};

const clientConfig = {
const bundle = {
...common,

entry: {
Expand Down Expand Up @@ -106,7 +106,7 @@ module.exports = (params = {}) => {
},
}

const serverConfig = {
const crosslink = {
...common,
target: 'node',
entry: {
Expand All @@ -122,5 +122,5 @@ module.exports = (params = {}) => {
},
}

return [clientConfig, serverConfig];
return [bundle, crosslink];
};

0 comments on commit 34cede6

Please sign in to comment.