Skip to content

Commit

Permalink
Work for #269: fix no file chosen caption doesnt change locale
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Sep 11, 2023
1 parent cac0b48 commit 4377925
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/flat_layout/flat_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class FlatFile extends FlatQuestion {
public async generateFlatsContent(point: IPoint): Promise<IPdfBrick[]> {
if (this.question.previewValue.length === 0) {
return [await SurveyHelper.createTextFlat(point, this.question,
this.controller, surveyLocalization.getString('noFileChosen'), TextBrick)];
this.controller, this.question.noFileChosenCaption, TextBrick)];
}
const rowsFlats: CompositeBrick[] = [new CompositeBrick()];
const currPoint: IPoint = SurveyHelper.clone(point);
Expand Down
22 changes: 22 additions & 0 deletions tests/flat_file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ test('Check no files', async () => {
<Question>survey.getAllQuestions()[0], controller, 'No file chosen', TextBrick);
TestHelper.equalRect(expect, flats[0][0], assumeFile);
});
test('Check noFileChosen locale', async () => {
let json: any = {
elements: [
{
type: 'file',
name: 'faque',
titleLocation: 'hidden'
}
]
};
let survey: SurveyPDF = new SurveyPDF(json, TestHelper.defaultOptions);
survey.getAllQuestions()[0].noFileChosenCaption = 'test';
let controller: DocController = new DocController(TestHelper.defaultOptions);
let flats: IPdfBrick[][] = await FlatSurvey.generateFlats(survey, controller);
expect(flats.length).toBe(1);
expect(flats[0].length).toBe(1);
controller.margins.left += controller.unitWidth;
let assumeFile: IRect = await SurveyHelper.createTextFlat(controller.leftTopPoint,
<Question>survey.getAllQuestions()[0], controller, 'test', TextBrick);
TestHelper.equalRect(expect, flats[0][0], assumeFile);
expect((<TextBrick>(<CompositeBrick>flats[0][0])['bricks'][0])['text']).toEqual('test');
});
test('Check one text file', async () => {
let json: any = {
elements: [
Expand Down

0 comments on commit 4377925

Please sign in to comment.