Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
node-version: '20'
- name: Install packages
run: npm ci
- name: Build (verifies types)
run: npm run build
- name: Run tests
run: npm test
2 changes: 1 addition & 1 deletion CNAME
Original file line number Diff line number Diff line change
@@ -1 +1 @@
aura.lightward.com
aura.lightward.io
57 changes: 57 additions & 0 deletions __tests__/aura-library.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Tests for Aura library build
* Verifies that the IIFE build exports correctly and can be used via script tag
*/

const fs = require('fs');
const path = require('path');
const vm = require('vm');

describe('Aura Library', () => {
let LightwardAura;

beforeAll(() => {
// Load the built library
const libraryPath = path.join(__dirname, '../dist/aura.js');
const libraryCode = fs.readFileSync(libraryPath, 'utf8');

// Create a sandbox with a window object
const sandbox = { window: {}, self: {} };

// Execute the library code in the sandbox
vm.runInNewContext(libraryCode, sandbox);

// The IIFE assigns to the global scope (window in browser, this in Node)
LightwardAura = sandbox.LightwardAura;
});

test('library file exists', () => {
const libraryPath = path.join(__dirname, '../dist/aura.js');
expect(fs.existsSync(libraryPath)).toBe(true);

const stats = fs.statSync(libraryPath);
expect(stats.size).toBeGreaterThan(1000); // Should be a substantial file
});

test('exports LightwardAura', () => {
expect(LightwardAura).toBeDefined();
// IIFE export could be function or object depending on module structure
expect(['function', 'object']).toContain(typeof LightwardAura);
});

test('LightwardAura exports Aura class', () => {
// Check if it's exported as default or directly
const Aura = LightwardAura.default || LightwardAura;

expect(Aura).toBeDefined();
expect(typeof Aura).toBe('function');
});

test('Aura class has expected constructor signature', () => {
const Aura = LightwardAura.default || LightwardAura;

// Check constructor exists and expects parameters
expect(typeof Aura).toBe('function');
expect(Aura.length).toBeGreaterThan(0); // Has parameters (gl, options)
});
});
18 changes: 18 additions & 0 deletions dist/aura.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
testEnvironment: 'jsdom',
testMatch: ['**/__tests__/**/*.test.js'],
collectCoverageFrom: ['dist/aura.js'],
};
Loading