import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
import { resolveExclusiveLoadingStyle } from './animation-exclusivity';
const suite = createLogicSuite('resolveExclusiveLoadingStyle');
suite('leaves a selection with only the dots loading style untouched', () => {
    const next = ['loading', 'halo'];
    assert.equal(resolveExclusiveLoadingStyle(next, ['halo']), ['loading', 'halo']);
});
suite('leaves a selection with only the waves loading style untouched', () => {
    const next = ['waves', 'halo'];
    assert.equal(resolveExclusiveLoadingStyle(next, ['halo']), ['waves', 'halo']);
});
suite('leaves a selection with no loading style untouched', () => {
    assert.equal(resolveExclusiveLoadingStyle(['halo'], []), ['halo']);
});
suite('drops dots when waves was just added on top of dots', () => {
    // Previously dots was on; user ticks waves → waves wins, dots removed.
    const result = resolveExclusiveLoadingStyle(['loading', 'waves', 'halo'], ['loading', 'halo']);
    assert.equal(result, ['waves', 'halo']);
});
suite('drops waves when dots was just added on top of waves', () => {
    // Previously waves was on; user ticks dots → dots wins, waves removed.
    const result = resolveExclusiveLoadingStyle(['loading', 'waves', 'halo'], ['waves', 'halo']);
    assert.equal(result, ['loading', 'halo']);
});
suite('preserves the order of the surviving selection', () => {
    const result = resolveExclusiveLoadingStyle(['halo', 'loading', 'waves'], ['halo', 'loading']);
    // waves was just added → loading dropped; halo and waves keep their order.
    assert.equal(result, ['halo', 'waves']);
});
suite('falls back to dots when both are present with no prior state (e.g. bad config)', () => {
    const result = resolveExclusiveLoadingStyle(['loading', 'waves', 'halo'], []);
    assert.equal(result, ['loading', 'halo']);
});
suite('falls back to dots when both were already present (neither newly added)', () => {
    const result = resolveExclusiveLoadingStyle(['loading', 'waves'], ['loading', 'waves', 'halo']);
    assert.equal(result, ['loading']);
});
suite('handles an empty selection', () => {
    assert.equal(resolveExclusiveLoadingStyle([], ['loading']), []);
});
suite('switching between any two loading styles keeps only the newly added one', () => {
    // flowingWaves was on; user picks plasma → plasma wins, flowingWaves dropped.
    assert.equal(resolveExclusiveLoadingStyle(['flowingWaves', 'plasma', 'halo'], ['flowingWaves', 'halo']), ['plasma', 'halo']);
    // plasma was on; user picks the dots → dots win, plasma dropped.
    assert.equal(resolveExclusiveLoadingStyle(['plasma', 'loading'], ['plasma']), ['loading']);
});
suite('drops all but the newly added style when several are somehow selected', () => {
    const result = resolveExclusiveLoadingStyle(['loading', 'waves', 'flowingWaves', 'plasma'], ['loading', 'waves', 'plasma']);
    // flowingWaves is the only one absent from `previous`, so it wins.
    assert.equal(result, ['flowingWaves']);
});
suite.run();
