|
1 | 1 | import { describe, it, expect } from 'vitest'; |
| 2 | +import * as fs from 'node:fs'; |
| 3 | +import * as path from 'node:path'; |
| 4 | +import { fileURLToPath } from 'node:url'; |
2 | 5 | import { renderStub, renderTsConfig } from '../src/init-template.js'; |
3 | 6 |
|
| 7 | +const TEMPLATE_PATH = path.resolve( |
| 8 | + path.dirname(fileURLToPath(import.meta.url)), |
| 9 | + '../src/agents.template.md' |
| 10 | +); |
| 11 | + |
4 | 12 | describe('renderStub', () => { |
5 | 13 | describe('when called with a name', () => { |
6 | 14 | it('returns a string', () => { |
@@ -104,3 +112,73 @@ describe('renderTsConfig', () => { |
104 | 112 | }); |
105 | 113 | }); |
106 | 114 | }); |
| 115 | + |
| 116 | +describe('agents.template.md', () => { |
| 117 | + let content: string; |
| 118 | + |
| 119 | + describe('when read from disk', () => { |
| 120 | + it('exists', () => { |
| 121 | + expect(fs.existsSync(TEMPLATE_PATH)).toBe(true); |
| 122 | + }); |
| 123 | + |
| 124 | + it('ends with a newline', () => { |
| 125 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 126 | + expect(content.endsWith('\n')).toBe(true); |
| 127 | + }); |
| 128 | + }); |
| 129 | + |
| 130 | + describe('project context', () => { |
| 131 | + it('identifies this as a Workday Everywhere plugin project', () => { |
| 132 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 133 | + expect(content).toContain('Workday Everywhere'); |
| 134 | + }); |
| 135 | + |
| 136 | + it('names the entry point file', () => { |
| 137 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 138 | + expect(content).toContain('plugin.tsx'); |
| 139 | + }); |
| 140 | + }); |
| 141 | + |
| 142 | + describe('data provider guidance', () => { |
| 143 | + it('mentions DataProvider', () => { |
| 144 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 145 | + expect(content).toContain('DataProvider'); |
| 146 | + }); |
| 147 | + |
| 148 | + it('mentions DataResolver', () => { |
| 149 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 150 | + expect(content).toContain('DataResolver'); |
| 151 | + }); |
| 152 | + }); |
| 153 | + |
| 154 | + describe('peer dependency guidance', () => { |
| 155 | + it('mentions react as a peer dependency', () => { |
| 156 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 157 | + expect(content.toLowerCase()).toContain('peer'); |
| 158 | + }); |
| 159 | + |
| 160 | + it('mentions react', () => { |
| 161 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 162 | + expect(content).toContain('react'); |
| 163 | + }); |
| 164 | + }); |
| 165 | + |
| 166 | + describe('import convention guidance', () => { |
| 167 | + it('calls out the .js extension requirement', () => { |
| 168 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 169 | + expect(content).toContain('.js'); |
| 170 | + }); |
| 171 | + }); |
| 172 | + |
| 173 | + describe('example references', () => { |
| 174 | + it('links to the hello example', () => { |
| 175 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 176 | + expect(content).toContain('examples/hello'); |
| 177 | + }); |
| 178 | + |
| 179 | + it('links to the directory example', () => { |
| 180 | + content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); |
| 181 | + expect(content).toContain('examples/directory'); |
| 182 | + }); |
| 183 | + }); |
| 184 | +}); |
0 commit comments